<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div id="uploader" class="wu-example">
		    <!--用来存放文件信息-->
		    <div id="thelist" class="uploader-list"></div>
		    <div class="btns">
		        <div id="picker">选择文件</div>
		        <input type="" name="" id="" value="" data-role = "123"/>
		    </div>
		</div>
		<script src="../../../framework/jQuery/jquery-3.0.0.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../../framework/webuploader-0.1.5/webuploader.css">
		<script type="text/javascript" src="../../../framework/webuploader-0.1.5/webuploader.js"></script>
		<script type="text/javascript">
			var uploader = WebUploader.create({
				auto:true,
			    swf:'Uploader.swf',
			    server: 'demo.php',
			    pick: '#picker',
			    chunked: true,
			    chunkSize:1024*1024
			});
			$list=$("#thelist");
			
			// 当有文件被添加进队列的时候
			uploader.on( 'fileQueued', function( file ) {
			    $list.append( '<div id="' + file.id + '" class="item">' +
			        '<h4 class="info">' + file.name + '</h4>' +
			        '<p class="state">等待上传...</p>' +
			    '</div>' );
			});
			// 文件上传过程中创建进度条实时显示。
			uploader.on( 'uploadProgress', function( file, percentage ) {
			    var $li = $( '#'+file.id ),
			        $percent = $li.find('.progress .progress-bar');
			
			    // 避免重复创建
			    if ( !$percent.length ) {
			        $percent = $('<div class="progress progress-striped active">' +
			          '<div class="progress-bar" role="progressbar" style="width: 0%">' +
			          '</div>' +
			        '</div>').appendTo( $li ).find('.progress-bar');
			    }
			
			    $li.find('p.state').text('上传中');
			
			    $percent.css( 'width', percentage * 100 + '%' );
			});
			//成功、失败时的处理
			uploader.on( 'uploadSuccess', function( file ) {
			    $( '#'+file.id ).find('p.state').text('已上传');
			});
			
			uploader.on( 'uploadError', function( file ) {
			    $( '#'+file.id ).find('p.state').text('上传出错');
			});
			
			uploader.on( 'uploadComplete', function( file ) {
			    $( '#'+file.id ).find('.progress').fadeOut();
			});
		</script>
	</body>
</html>
